package cc.liyinghao.controller;


import cc.liyinghao.service.WebSocketService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/online")
@RequiredArgsConstructor
@Api(tags = "在线信息路由")
public class OnlineController {

    private final WebSocketService webSocketService;

    @GetMapping("/get_online")
    @ApiOperation(value = "获取全部的在线用户")
    public List<String> sendMessage() {
        return webSocketService.getOnlineUser();
    }

    @GetMapping("/get_online_number")
    @ApiOperation(value = "获取在线用户的数量")
    public int getOnlineNumber() {
        return webSocketService.getOnlineNum();
    }
}
